package com.xinqi.util.threadfactory;

import com.xinqi.util.thread.XinThread;
import io.netty.util.concurrent.DefaultThreadFactory;
import io.netty.util.concurrent.FastThreadLocalThread;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
//TODO 待测试
/**
 * @author xin麒
 * @date 2023/8/24 6:37
 */
public class XinThreadFactory extends DefaultThreadFactory{

    public XinThreadFactory(Class<?> poolType) {
        super(poolType);
    }

    public XinThreadFactory(String poolName) {
        super(poolName);
    }

    public XinThreadFactory(Class<?> poolType, boolean daemon) {
        super(poolType, daemon);
    }

    public XinThreadFactory(String poolName, boolean daemon) {
        super(poolName, daemon);
    }

    public XinThreadFactory(Class<?> poolType, int priority) {
        super(poolType, priority);
    }

    public XinThreadFactory(String poolName, int priority) {
        super(poolName, priority);
    }

    public XinThreadFactory(Class<?> poolType, boolean daemon, int priority) {
        super(poolType, daemon, priority);
    }

    public XinThreadFactory(String poolName, boolean daemon, int priority, ThreadGroup threadGroup) {
        super(poolName, daemon, priority, threadGroup);
    }

    public XinThreadFactory(String poolName, boolean daemon, int priority) {
        super(poolName, daemon, priority);
    }

    @Override
    protected Thread newThread(Runnable r, String name) {
        return new XinThread(this.threadGroup, r, name);
    }
}
/*

public class XinThreadFactory implements ThreadFactory {
    private static final AtomicInteger poolNumber = new AtomicInteger(1);
    private final ThreadGroup group;
    private final AtomicInteger threadNumber = new AtomicInteger(1);
    private final String namePrefix;

    XinThreadFactory() {
        SecurityManager s = System.getSecurityManager();
        group = (s != null) ? s.getThreadGroup() :
                Thread.currentThread().getThreadGroup();
        namePrefix = "pool-" +
                poolNumber.getAndIncrement() +
                "-thread-";
    }

    public Thread newThread(Runnable r) {
        Thread t = new Thread(group, r,
                namePrefix + threadNumber.getAndIncrement(),
                0);
        if (t.isDaemon())
            t.setDaemon(false);
        if (t.getPriority() != Thread.NORM_PRIORITY)
            t.setPriority(Thread.NORM_PRIORITY);
        return t;
    }
}
*/
